import 'package:flutter/material.dart';

class LifeCycleWidget extends StatefulWidget {
  LifeCycleWidget() {
    print('1.LifeCycleWidget构造方法');
  }

  @override
  _LifeCycleWidgetState createState() {
    print('2.LifeCycleWidget=====createState');
    return _LifeCycleWidgetState();
  }
}

class _LifeCycleWidgetState extends State<LifeCycleWidget> {
  _LifeCycleWidgetState() {
    print("3._LifeCycleWidgetState构造方法");
  }

  @override
  void initState() {
    print("4._LifeCycleWidgetState=====initState");
    //存在注解 @mustCallSuper，super必须调用
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    debugPrint("5._LifeCycleWidgetState=====build");
    return Scaffold(
      appBar: AppBar(
        title: Text('生命周期'),
      ),
      body: Text('实例'),
    );
  }

  @override
  void didUpdateWidget(LifeCycleWidget oldWidget) {
    print("didUpdateWidget");
    super.didUpdateWidget(oldWidget);
  }

  @override
  void deactivate() {
    print("deactive");
    super.deactivate();
  }

  @override
  void dispose() {
    print("dispose");
    super.dispose();
  }

  @override
  void reassemble() {
    print("reassemble");
    super.reassemble();
  }

  @override
  void didChangeDependencies() {
    print("didChangeDependencies");
    super.didChangeDependencies();
  }
}
